#include <iostream>
#include "../source/log.h"
#include "../source/util.h"


// using namespace std;
int main()
{
    std::cout<<"test..."<<std::endl;

    sylar::Logger::ptr logger(new sylar::Logger);
    sylar::LogAppender::ptr std_appender = sylar::LogAppender::ptr(new sylar::StdoutLogAppender);
    // sylar::LogFormatter::ptr fmt(new sylar::LogFormatter("%D%T%p%T%m%n"));
    std_appender->setLevel(sylar::LogLevel::DEBUG);

    logger->addAppender(std_appender);

    // std::cout<<"Hellow sylar log..."<<std::endl;
    // sylar::FileLogAppender::ptr file_appender(new sylar::FileLogAppender("./log.txt"));
    // file_appender->setFormatter(fmt);
    // file_appender->setLevel(sylar::LogLevel::ERROR);

    // logger->addAppender(file_appender);

    sylar::LogEvent::ptr event(new sylar::LogEvent(logger, sylar::LogLevel::UNKNOW, __FILE__, __LINE__, 0, sylar::GetThreadId(), sylar::GetFiberId(), time(0), "test name"));
    event->getSS() << "hello sylar log";
    logger->log(sylar::LogLevel::ERROR, event);


    SYLAR_LOG_DEBUG(logger) << "test info";
    SYLAR_LOG_INFO(logger) << "test macro";
    SYLAR_LOG_ERROR(logger) << "test macro error";
    // SYLAR_LOG_FMT_LEVEL(logger, "test macro fmt error %s", "aa");
    SYLAR_LOG_FMT_ERROR(logger, "test macro fmt error %s", "aa");

    auto l = sylar::LoggerMgr::GetInstance()->getLogger("xx");
    SYLAR_LOG_INFO(l) << "xxx";
    SYLAR_LOG_LEVEL(logger, sylar::LogLevel::DEBUG) << "test macro";


    return 0;
}